﻿using MengLin.OOP.DesignPattern.CompsitePattern.BasicCode.Abstract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MengLin.OOP.DesignPattern.CompsitePattern.BasicCode.Implements
{
    /// <summary>
    /// 叶子节点
    /// </summary>
    public class Leaf : AbstractComponent
    {
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="name"></param>
        public Leaf(string name): base(name)
        {

        }

        /// <summary>
        /// 添加叶子节点
        /// </summary>
        /// <param name="component"></param>
        public override void Add(AbstractComponent component)
        {
            Console.WriteLine("Cannot add to a leaf.");
        }

        /// <summary>
        /// 删除叶子节点
        /// </summary>
        /// <param name="component"></param>
        public override void Remove(AbstractComponent component)
        {
            Console.WriteLine("Cannot remove from a leaf.");
        }

        /// <summary>
        /// 显示部分与整体的层次结构
        /// </summary>
        /// <param name="depth">深度</param>
        public override void Display(int depth)
        {
            Console.WriteLine(new String('-', depth) + _name);
        }
    }
}
